#!/usr/bin/env python
# -*- coding:utf-8 -*-


from requests import Session
from zeep import Client
from zeep.transports import Transport
from tkinter import *
import configparser


class Win(Tk):
	def init(self):
		self.geometry('500x600')
		self.geometry('+500+100')
		cfg = configparser.ConfigParser()
		cfg.read('config.ini', encoding='utf-8')
		url = cfg.get('base', 'url')
		print(url)
		session = Session()    # 这里是因为url是https，不然不需要transport
		session.verify = False
		transport = Transport(session=session)
		self.client = Client(url, transport=transport)
		self.initFrame()

	def test_match(self):
		text = self.client.service.zbzMatching(self.input_txt.get(1.0, END))
		self.output_txt.delete(1.0, END)
		self.output_txt.insert(INSERT, text)

	def test_clrk(self):
		text = self.client.service.vehicleWarehousing(self.input_txt.get(1.0, END))
		self.output_txt.delete(1.0, END)
		self.output_txt.insert(INSERT, text)

	def initFrame(self):
		button_bar_frame = Frame(self)
		Button(button_bar_frame, text='匹配', command=self.test_match).pack(side='left')
		Button(button_bar_frame, text='入库', command=self.test_clrk).pack(side='left')
		button_bar_frame.pack(side='top')

		text_frame = Frame(self)
		self.input_txt = Text(text_frame)
		self.input_txt.pack()
		self.output_txt = Text(text_frame)
		self.output_txt.pack()
		text_frame.pack(side='bottom')


win = Win()
win.init()
win.mainloop()